package docoffice.gui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JPanel;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTextField;
import javax.swing.JPasswordField;

import javax.swing.JButton;

/**
 * Login GUI
 * 
 * Will allow the user to interact with a screen 
 * that will allow them to login to the system.
 * 
 * @author Jackie Trujillo
 * @version $Revision: 1.0 $
 */
public class Login {

	/**
	 * Field frame.
	 */
	private JFrame frame;

	/**
	 * Field textField.
	 */
	private JTextField textField;

	/**
	 * Field passwordField.
	 */
	private JPasswordField passwordField;

	/**
	 * Launch the application.
	 * @param args String[]
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					final Login window = new Login();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Login() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		final JLabel lblDoctorsOfficeSupport = new JLabel("Doctor's Office Support System");
		lblDoctorsOfficeSupport.setFont(new Font("Engravers MT", Font.PLAIN, 16));
		
		final JLabel lblName = new JLabel("Username");
		
		final JLabel lblPassword = new JLabel("Password");
		
		textField = new JTextField();
		textField.setColumns(10);
		
		passwordField = new JPasswordField();
		
		final JButton btnLogin = new JButton("Login");
		
		btnLogin.addActionListener(new ButtonListener());
		
		final GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(33)
							.addComponent(lblDoctorsOfficeSupport))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(71)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblPassword)
								.addComponent(lblName))
							.addGap(31)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
								.addComponent(passwordField)
								.addComponent(textField))))
					.addContainerGap(32, Short.MAX_VALUE))
				.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
					.addContainerGap(275, Short.MAX_VALUE)
					.addComponent(btnLogin)
					.addGap(58))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(34)
					.addComponent(lblDoctorsOfficeSupport)
					.addGap(49)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblName)
						.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(30)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblPassword)
						.addComponent(passwordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(30)
					.addComponent(btnLogin)
					.addContainerGap(43, Short.MAX_VALUE))
		);
		
		frame.getContentPane().setLayout(groupLayout);
	}
	
	/**
	 */
	private static class ButtonListener implements ActionListener {
		/**
		 * Method actionPerformed.
		 * @param e ActionEvent
		 * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
		 */
		public void actionPerformed(ActionEvent e) {
//			System.out.println("Button1 has been clicked"); // test
			JFrame newFrame = new JFrame();
			PatientGUI newPGUI = new PatientGUI();
			newFrame.getContentPane();
		}
		
		/**
		 * Method toString for ButtonListener class.
		
		 * @return String */
		public String toString() {
			return "ButtonListener toString";
		}
	}
	
	/**
	 * Method toString.
	
	 * @return String */
	public String toString() {
		return "Login GUI";
	}

}
